package com.yc.thread;

import java.text.SimpleDateFormat;
import java.util.Date;

/***
 * 优先级
 */
public class Test10_priority {
    public static void main(String[] args) {
        ShowTime2 task=new ShowTime2();
        Thread stt=new Thread(task);
        stt.setPriority(10);
        stt.setName("线程1");//设置线程名
        stt.start();

        Thread t=new Thread(task,"线程2");
        t.setPriority(1);
        t.start();
    }
}

class ShowTime2 implements Runnable{
    @Override
    //run加入线程完成的操作
    public void run(){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss S");
        Date d=null;
        while (true){
            d=new Date();
            System.out.println(Thread.currentThread().getName()+"当前时间为："+sdf.format(d));
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}